//
//  UIButten + extension.swift
//  WeiBo09
//
//  Created by 裘明 on 15/9/13.
//  Copyright © 2015年 qm. All rights reserved.
//

import UIKit

extension UIButton {
    
    /// 遍历构造函数
    ///
    /// - parameter title:      title
    /// - parameter imageName:  imagename
    /// - parameter titleColor: titleColor
    /// - parameter fontSize:   fontSize
    ///
    /// - returns: UIButten
    convenience init(title: String, imageName: String, titleColor: UIColor, fontSize: CGFloat) {
        self.init()
        setTitle(title, forState: UIControlState.Normal)
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setTitleColor(titleColor, forState: UIControlState.Normal)
        
        titleLabel?.font = UIFont.systemFontOfSize(fontSize)
    }
    
    /// 遍历构造函数
    ///
    /// - parameter imageName: imageName
    ///
    /// - returns: UIButten
    convenience init(imageName: String) {
        self.init()
        
        setImage(UIImage(named: imageName), forState: UIControlState.Normal)
        setImage(UIImage(named: imageName + "_highlighted"), forState: UIControlState.Highlighted)
        sizeToFit()
    }
}
